/**
 * Created by w2ex on 7/1/16.
 */
const path = require('path');
const webpack = require('webpack');
const webappRoot = path.join(__dirname, 'src');
const buildRoot = path.join(__dirname, 'dist');
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    context: webappRoot,

    entry: './app.js',

    output: {
        path: buildRoot,
        filename: 'app.bundle.js'
    },

    devtool: 'inline-source-map',

    module: {
        preLoaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'eslint'
            }
        ],
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader?presets[]=es2015&presets[]=react'
            },
            {
                test: /\.scss$/,
                loaders: ["style", "css", "sass"]
            },
            {
                test: /\.css$/,
                loaders: ["style", "css", "sass"]
            },
            {
                test: /\.font\.(json|js)$/,
                loader: 'style!css!fontgen?embed&types=woff'
            },
            {
                test: /\.(png|jpg|gif)$/,
                loader: 'url?limit=2000'
            }
        ]
    },

    devServer: {
        contentBase: webappRoot
    },

    eslint: {
        configFile: './.eslintrc.json',
        failOnWarning: false,
        failOnError: true
    },

    plugins: [
        // !!!Attention: This plugin introduce adventive building exception, so disabled it in DEV mode.
        //new webpack.optimize.DedupePlugin()
    ]
}
